package utils

import (
	"bytes"
	"sync"
)

var BufPoolUtil = &BufPoolUtilTool{}
var pool = sync.Pool{
	New: func() interface{} { return new(bytes.Buffer) },
}

type BufPoolUtilTool struct{}

func (*BufPoolUtilTool) GetBufToFuc(run func(*bytes.Buffer)) {
	buf := pool.Get().(*bytes.Buffer)
	defer func() {
		pool.Put(buf)
		buf.Reset()
	}()
	run(buf)
}
